package org.huangxiaozhe.adventure;

import com.triplefstudio.adventure.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity implements OnClickListener{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ((Button)findViewById(R.id.settings_button)).setOnClickListener(this);
        ((Button)findViewById(R.id.about_button)).setOnClickListener(this);
        ((Button)findViewById(R.id.exit_button)).setOnClickListener(this);
        ((Button)findViewById(R.id.play_button)).setOnClickListener(this);
    }

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	public void onClick(View v) {
		switch(v.getId()){
		case R.id.play_button:
			Intent intent = new Intent(this, PlayActivity.class);
			intent.putExtra("abc", "xyz");
			this.startActivity(intent);
			break;
		case R.id.settings_button:
			
			break;
		case R.id.about_button:
			openAboutDialog();
			break;
		case R.id.exit_button:
			this.finish();
			break;
		}
	}
	
	private void openAboutDialog() {
		// TODO Auto-generated method stub
		new AlertDialog.Builder(MainActivity.this)
		.setTitle(R.string.about_title)
		.setMessage(R.string.about_text)
		.setPositiveButton(R.string.return_label, 
				new DialogInterface.OnClickListener() {
					
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						
					}
				})
		.show();
	}
}